#include"Heap.h"
void HeapSort(int* arr, int size) {
	for (int i = 0; i < size; i++) {
		AdJustUP(arr, i);
	}
	for (int i = 0; i < 6; i++) {
		printf("%d ", arr[i]);
	}
	printf("\n");
	int end = size - 1;
	while (end >= 0) {
		Swap(&arr[end], &arr[0]);
		AdJustDown(arr, 0, end);
		end--;
	}
}//堆排序
void test01() {
	int arr[] = { 3,15,4,12,8,20 };
	HeapSort(arr, 6);
	for (int i = 0; i < 6; i++) {
		printf("%d ", arr[i]);
	}
	printf("\n");
}
void test02() {
	Heap hp;
	HPInit(&hp);
	HPPush(&hp, 3);
	HPPush(&hp, 15);
	HPPush(&hp, 4);
	HPPush(&hp, 12);
	HPPush(&hp, 8);
	HPPush(&hp, 20);
	while (!HPEmpty(&hp)) {
		printf("%d ", HPTop(&hp));
		HPPop(&hp);
	}
	HPDestroy(&hp);
}
int main() {
	test01();
	return 0;
}